/**
 * Copyright 2008 Matthew DeLambo
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.delambo.drool.pooling;

import com.delambo.drool.interfaces.PropertyMap;
import java.util.*;

public final class Pool_PropertyMap_Impl implements PropertyMap<String, Object> {
    Map<String, Object> prop_set = new HashMap<String, Object>();
    
    public Pool_PropertyMap_Impl() {}
    
    public void loadProperties(final String fileName) {
        final ResourceBundle rb = ResourceBundle.getBundle(fileName);
        prop_set.put("DATABASE", rb.getString("DATABASE"));
        prop_set.put("DB_USERNAME", rb.getString("DB_USERNAME"));
        prop_set.put("DB_PASSWORD", rb.getString("DB_PASSWORD"));
        prop_set.put("CP_SIZE", Integer.parseInt(rb.getString("CP_SIZE")));
        prop_set.put("AUTO_COMMIT", new Boolean("AUTO_COMMIT"));
        prop_set.put("RETRY_ATTEMPTS", Integer.parseInt(
                rb.getString("RETRY_ATTEMPTS")));
        prop_set.put("NODE_EXPIRATION_TIME", Integer.parseInt(
                rb.getString("NODE_EXPIRATION_TIME")));
        prop_set.put("CONN_LEASE_TIME", Integer.parseInt(
                rb.getString("CONN_LEASE_TIME")));
        prop_set.put("CLEANUP_STYLE", rb.getString("CLEANUP_STYLE"));
        prop_set.put("CP_CLEANUP_INTERVAL", Integer.parseInt(
                rb.getString("CP_CLEANUP_INTERVAL")));
        prop_set.put("RETRY_WAIT_PERIOD", Integer.parseInt(
                rb.getString("RETRY_WAIT_PERIOD")));
        prop_set.put("DRIVER", rb.getString("DRIVER"));
    }
    
    public Object getProperty(String property) {
        return this.prop_set.get(property);
    }
}
